var txtPrizeCount = document.querySelector('.container .prizearea .prizecontent .prizsesize3 span');
var btnPirze = document.querySelector('.container .prizearea .prizecontent .prizsesize3 img:last-child');
var prizeList = document.querySelectorAll('.container .prizearea .prizecontent .prizestyle');

var prizeSize = prizeList.length;
var curChekcedPosi = 0;
var canPrizeNum = 0;

function init() {
  initEvent();
}

function initEvent() {
  btnPirze.addEventListener('click', function () {
    if (canPrizeNum <= 0) {
      alert('抽奖次数已用完');
      return;
    }

    startPrize();
  });
}

function startPrize() {
  var baseNum=2*prizeSize;
  var randomNum=getRandom(baseNum, prizeSize);
  checkSinglePrize(randomNum);
}

function checkSinglePrize(randomNum) {
    setTimeout(() => {
        randomNum--;
        if (randomNum <=0 ) {
            return
        }
      }, 500);
}

function getRandom(min, max) {
  max += 1;
  return Math.floor(Math.random() * (max - min) + min);
}
init();
